/*
 * @ProjectName: 编程学习
 * @Copyright:   2019 HangZhou Yi Dev, Ltd. All Right Reserved.
 * @address:     https://yiyuery.github.io/
 * @date:        2019/12/14 7:45 下午
 * @email:       xiazhaoyang@live.com
 * @description: 本内容仅限于编程技术学习使用，转发请注明出处.
 */
package com.example.spring.aop.advisor;

import com.example.spring.aop.service.impl.PersonManagerProxyService;
import com.example.spring.aop.service.impl.PersonManagerServiceImpl;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.aop.ClassFilter;
import org.springframework.aop.MethodMatcher;
import org.springframework.aop.Pointcut;
import org.springframework.aop.support.ComposablePointcut;
import org.springframework.aop.support.ControlFlowPointcut;
import org.springframework.aop.support.DynamicMethodMatcherPointcut;
import org.springframework.aop.support.NameMatchMethodPointcut;

import java.lang.reflect.Method;

/**
 * <p>
 *
 * </p>
 *
 * @author Yi
 * @version V1.0.0
 * @date 2019/12/14 7:45 下午
 * @modificationHistory=========================逻辑或功能性重大变更记录
 * @modify By: {修改人}  2019/12/14
 * @modify reason: {方法名}:{原因}
 * ...
 */
@Slf4j
public class BusinessLogHandlerComposablePointcut extends ComposablePointcut{

    public BusinessLogHandlerComposablePointcut() {
        Pointcut simpleAddPointCut = new ControlFlowPointcut(PersonManagerProxyService.class, "simpleAdd");

        Pointcut nameMatchMethodPointcut = new NameMatchMethodPointcut();
        ((NameMatchMethodPointcut)nameMatchMethodPointcut).setMappedName("simpleAddPersonWithFilter");

        this.intersection(simpleAddPointCut).intersection(nameMatchMethodPointcut);
    }
}
